<template>
	<view class="payWay_continer">
		<web-view :src="src"></web-view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				// 地址
				src: null,
			}
		},
		onShow() {
			this.src = this.zfbUrl
			this.getmsg()
			console.log(this.orderInfo, '完整订单信息+++++++++')
		},
		computed: {
			...mapState('userInfo', ['zfbUrl', 'userSocketID', 'orderInfo', 'couponsInfo'])
		},
		methods: {
			...mapMutations('userLocation', ['getEnd', 'getStart']),
			getmsg() {
				this.socket.on('messageUser', async message => {
					// 改变优惠卷状态
					if (this.couponsInfo) {
						const result = await this.$http('/couponsState', {
							// 优惠卷id
							couponsID: this.couponsInfo,
							//乘客id
							userID: this.userSocketID,
						})
						if (result.code !== 200) return console.log('改变优惠卷状态失败')
					} else {
						console.log('没有使用优惠卷')
					}

					// 修改订单状态
					let obj = {
						type: '支付宝', //支付类型
						orderNum: this.orderInfo.ordernum, //订单号
					}
					const orderState = await this.$http('/OrderStateUser', obj, 'POST')
					if (orderState.code !== 200) return console.log('改变订单状态失败')
					// 清空 仓库地址
					this.getStart('')
					this.getEnd('')
					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/home/home'
						})
					}, 1000)
				})
			},

		},
	}
</script>

<style>

</style>
